package logic

import (
	"anjuke/anjukerpc/models"
	"context"
	"gorm.io/gorm"

	"anjuke/anjukerpc/anjukerpc"
	"anjuke/anjukerpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShowLogic) Show(in *anjukerpc.ShowRequest) (*anjukerpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	user := models.House{
		Model: gorm.Model{ID: uint(in.Id)},
	}
	models.DB.Where("id=?", in.Id).Find(&user)
	return &anjukerpc.ShowResponse{
		Name:    user.Name,
		Content: user.Content,
		Address: user.Address,
	}, nil
}
